package com.shenzhen.horselive.ui.dialog;

import android.accessibilityservice.AccessibilityService;
import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;

import com.shenzhen.horselive.R;
import com.shenzhen.horselive.databinding.DialogInputPassBinding;
import com.shenzhen.horselive.databinding.DialogLoginBinding;
import com.shenzhen.horselive.widget.VerificationCodeInput;

public class InputDialog extends Dialog {

    private  OnInputFinsh  onInputFinsh;

    public void setOnInputFinsh(OnInputFinsh onInputFinsh) {
        this.onInputFinsh = onInputFinsh;
        if (binding!=null&&binding.verificationCodeInput!=null)
        {
            binding.verificationCodeInput.setOnCompleteListener(new VerificationCodeInput.Listener() {
                @Override
                public void onComplete(String content) {
                    dismiss();
                    if (onInputFinsh!=null)
                    {
                        onInputFinsh.onFinish(content);
                    }
                }
            });
        }
    }

    public InputDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    public InputDialog(Context context, int theme) {
        super(context, theme);
    }


    DialogInputPassBinding   binding;
    public InputDialog(Context context) {
        super(context, R.style.CommonDialog);
        //初始化
        binding = DialogInputPassBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        //键盘弹起
        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);

    }

    public   void  setTextName(String  string){
        binding.tvText.setText(string);
    }
    public   void  setTextContent(String  string){
        binding.tvMoney.setText(string);
    }
    @Override
    public void show() {
        super.show();
        WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
        layoutParams.width= ViewGroup.LayoutParams.MATCH_PARENT;
        layoutParams.height= ViewGroup.LayoutParams.WRAP_CONTENT;
        layoutParams.gravity = Gravity.CENTER;
        getWindow().setAttributes(layoutParams);

    }
    public   void   setInputDown(VerificationCodeInput.Listener  listener)
    {
        binding.verificationCodeInput.setOnCompleteListener(listener);
    }










    public  interface  OnInputFinsh{
        void  onFinish(String  s);
    }

}
